﻿#ifndef _CONFIGURE_H_
#define _CONFIGURE_H_

#include "AIGCJson/AIGCJson.hpp"

/*从配置文件读取数据*/
struct virtual_mac_config
{
    int         virtual_type;         /*虚拟网卡类型*/
    int         encrypt = 0;          /*是否加密*/
    std::string virtual_name1;        /*虚拟网卡对name1*/
    std::string virtual_name2;        /*虚拟网卡对name2*/
    std::string virtual_mac1;         /*虚拟网卡对mac1*/
    std::string virtual_mac2;         /*虚拟网卡对mac2*/
    std::string virtual_ip;           /*虚拟网卡对ip1*/

    AIGC_JSON_HELPER(virtual_type, encrypt, virtual_name1, virtual_name2)
};
/*初始化数据提供给程序使用*/
struct init_config
{
    std::list<virtual_mac_config>   virtuals;	    /*虚拟网卡信息*/
    std::string 	physical_name;                   /*物理网卡网卡名字*/
    std::string 	physical_mac;                   /*物理网卡网卡*/
    std::string     up_mac;
    int             m_encrypt = 0;     			    /*是否需要协商秘钥*/
    std::string     v2vproxy_ip;
    int             v2vproxy_port;
    AIGC_JSON_HELPER(virtuals,  physical_name, up_mac, v2vproxy_ip, v2vproxy_port)
};


class configure 
{
public:
    configure(){}
    ~configure(){}

    static configure* instance() { return &m_handler; }

    int load(const std::string& filename);
    int getmac(char *mac,const char *name);
    int getip(char *addr,const char *name);
    // inline int get_vir_type() { return m_config.virtual_type; }
    inline int get_encrypt() { return m_config.m_encrypt; }
    // inline std::string get_vir_mac() { return m_config.virtual_mac; }
    inline std::string get_phy_mac() { return m_config.physical_mac; }

    //inline const logconfig& get_log_config() { return m_config.log_config; }
    
public:

    static configure m_handler;

    init_config m_config;
    
    std::string m_path;
    
};


#endif